<?php
include "../utils/_connection.php";
$var = conectar();
session_start();

//LeArticleData
$title = $_POST['titulo'];
$abstract = mysql_real_escape_string($_POST['abs']);
$keywords = mysql_real_escape_string($_POST['key']);
$content = mysql_real_escape_string($_POST['content']);
$references = mysql_real_escape_string($_POST['references']);
$biography = mysql_real_escape_string($_POST['biography']);
$co_authors = $_POST['co-authors'];

	foreach ($_POST['co-authors'] as $co_author){
		$co_sql = "SELECT * FROM `coauthors` WHERE name = '$co_author'";
		$co_res = mysql_query($co_sql);
		$co_obj = mysql_fetch_object($co_res);

		$co .= "<h2>".$co_obj->name."</h2>";
		$co .= "<h2>".$co_obj->center."<br>"; 
		$co .= "<a href=''>".$co_obj->email."</a></h2>";
		$co .= "<br>";
	}
echo $co;
$id = $_SESSION['id'];

$insert = "INSERT INTO `articles`
			(`id_author`, `title`, `co_authors`, `abstract`, `keywords`, `category`, `content`, `references`, `biography`, `status`)
		   VALUES 
		   	('$id','$title','$co','$abstract','$keywords','$category','$content','$references','$biography', 'Pendiente')";

	mysql_query($insert);
	header('Location: /backend/autor/');
?>